package com.blrs.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.blrs.common.core.page.PageDomain;
import com.blrs.common.core.page.TableSupport;
import com.blrs.common.utils.page.PaginationUtil;
import com.blrs.service.teacherInfo.ITeacherInfoService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.blrs.common.annotation.Log;
import com.blrs.common.core.controller.BaseController;
import com.blrs.common.core.domain.AjaxResult;
import com.blrs.common.enums.BusinessType;
import com.blrs.domain.TeacherInfo;

import com.blrs.common.utils.poi.ExcelUtil;
import com.blrs.common.core.page.TableDataInfo;

/**
 * 师资管理Controller
 * 
 * @author ruoyi
 * @date 2023-07-17
 */
@RestController
@RequestMapping("/procure/teacherInfo")
public class TeacherInfoController extends BaseController
{
    @Autowired
    private ITeacherInfoService teacherInfoService;

    /**
     * 查询师资管理列表
     */
    //@PreAuthorize("@ss.hasPermi('procure:teacherInfo:list')")
    @GetMapping("/list")
    public TableDataInfo list(TeacherInfo teacherInfo)
    {
        startPage();
        List<TeacherInfo> list = teacherInfoService.selectTeacherInfoList(teacherInfo);
        return getDataTable(list);
    }

    /**
     * 导出师资管理列表
     */
    //@PreAuthorize("@ss.hasPermi('procure:teacherInfo:export')")
    @Log(title = "师资管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TeacherInfo teacherInfo)
    {
        List<TeacherInfo> list = teacherInfoService.selectTeacherInfoListExport(teacherInfo);
        ExcelUtil<TeacherInfo> util = new ExcelUtil<TeacherInfo>(TeacherInfo.class);
        util.exportExcel(response, list, "师资管理数据");
    }

    /**
     * 获取师资管理详细信息
     */
    //@PreAuthorize("@ss.hasPermi('procure:teacherInfo:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return success(teacherInfoService.selectTeacherInfoById(id));
    }

    /**
     * 新增师资管理
     */
    //@PreAuthorize("@ss.hasPermi('procure:teacherInfo:add')")
    @Log(title = "师资管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TeacherInfo teacherInfo) throws NoSuchFieldException, IllegalAccessException {
         return toAjax(teacherInfoService.insertTeacherInfo(teacherInfo));
    }

    /**
     * 修改师资管理
     */
    //@PreAuthorize("@ss.hasPermi('procure:teacherInfo:edit')")
    @Log(title = "师资管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TeacherInfo teacherInfo)
    {
        return toAjax(teacherInfoService.updateTeacherInfo(teacherInfo));
    }

    /**
     * 删除师资管理
     */
    //@PreAuthorize("@ss.hasPermi('procure:teacherInfo:remove')")
    @Log(title = "师资管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(teacherInfoService.deleteTeacherInfoByIds(ids));
    }
}
